clc
clear
clims = [0 6];
while (1)
    close all;
    axis equal;
    S = init_setup;
    S.field(1:2, 3:end) = 1;
    S.top(3:end) = 2;
    S.nextPiece = 0;
    imagesc(flipud(S.field), clims);
    axis equal;
    pause();
    while (~S.lost)
        action = ceil(rand()*size(S.legalMoves{S.nextPiece+1},1));
        S = makeMoveAction( S, action);
        imagesc(flipud(S.field), clims);
        axis equal;
        pause();
    end
end
